home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: natlab.research.philips.com!ijntema
- From: ijntema@natlab.research.philips.com (Hans IJntema)
- Subject: Re: what happens w/delete called twice ?
- Sender: news@natlab.research.philips.com (USENET News System)
- Message-ID: <ijntema.243.010270CF@natlab.research.philips.com>
- Date: Fri, 23 Feb 1996 14:25:29 GMT
- References: <kcc.423.0EE12CF6@interaccess.com>
- Organization: Philips Research
- X-Newsreader: Trumpet for Windows [Version 1.0 Rev B]
-
- In article <kcc.423.0EE12CF6@interaccess.com> kcc@interaccess.com (kcc) writes:
- >From: kcc@interaccess.com (kcc)
- >Subject: what happens w/delete called twice ?
- >Date: Thu, 22 Feb 1996 22:24:41
-
- >Hello,
-
- > Can someone tell me... what happens when delete is called twice for the same
- >memory deallocation ie.,
-
- > SOME_STRUCT *struct_p = new SOME STRUCT;
-
- > if ( foo_a() )
- > {
- > delete struct_p;
- > retvalue = 0;
- > }
- > else
- > {
- > retvalue = foo_b();
- > }
-
- > delete struct_p;
-
- > return( retvalue );
-
-
-
- >Thanx !
- >kcc
-
- Probably you will run into problems, which depends on OS, compiler etc..
- However, if you make the pointer NULL immediately after deleting, then
- everything is fine because deleting a NULL pointer is allowed.
- ___________________________________________________________________________
- Hans IJntema
- Philips Research
- Building WO-02
- Prof. Holstlaan 4
- 5656 AA Eindhoven
- The Netherlands
-
- e-mail: ijntema@natlab.research.philips.com
- Phone: +31 40 2743325 or 2742877
- Fax: +31 40 2742630
- ___________________________________________________________________________
-